//
// Created by xili on 2024/8/14 9:46.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int arithmeticTriplets(vector<int> &nums, int diff) {
        unordered_set<int> us(nums.begin(), nums.end());
        int ans = 0;
        for (auto &item: nums) {
            if (us.count(item - diff) && us.count(item - 2 * diff)) {
                ans++;
            }
        }
        return ans;
    }
};